package m3d28;

import java.util.HashMap;
import java.util.Map;

public class aMap {
    public static void main(String[] args) {
        Map<String,String> map1 = new HashMap<>();

        //key不重复，返回V是NULL
        //key重复，返回value会替换原来的，返回被替换的Value
        String v1 = map1.put("a","1");
        System.out.println(v1);
        String v2 = map1.put("a","2");
        System.out.println(v2);
        System.out.println(map1);
        System.out.println("=============");

        String v3 = map1.put("b","2");
        String v4 = map1.put("c","3");
        String v5 = map1.put("d","4");
        System.out.println(map1);
        System.out.println("=============");

        //key存在，返会被删的值，不存在返回null
        String v6 = map1.remove("d");
        String v7 = map1.remove("d");
        System.out.println(v6+v7);
        System.out.println("=============");

        //key存在，返会对应的值，不存在返回null
        String v8 = map1.get("c");
        System.out.println(v8);
        System.out.println("=============");

        //是否含有键
        boolean b = map1.containsKey("c");
        System.out.println(b);

    }
}
